<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/boost/smart_ptr/weak_ptr.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">usr/include/boost/smart_ptr</a> - weak_ptr.hpp<span style="font-size: 80%;"> (source / <a href="weak_ptr.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">3</td>
            <td class="headerCovTableEntry">4</td>
            <td class="headerCovTableEntryMed">75.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntryHi">-</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED</a>
<span class="lineNum">       2 </span>            : #define BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : //
<span class="lineNum">       5 </span>            : //  weak_ptr.hpp
<span class="lineNum">       6 </span>            : //
<span class="lineNum">       7 </span>            : //  Copyright (c) 2001, 2002, 2003 Peter Dimov
<span class="lineNum">       8 </span>            : //
<span class="lineNum">       9 </span>            : // Distributed under the Boost Software License, Version 1.0. (See
<span class="lineNum">      10 </span>            : // accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">      11 </span>            : // http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">      12 </span>            : //
<span class="lineNum">      13 </span>            : //  See http://www.boost.org/libs/smart_ptr/weak_ptr.htm for documentation.
<span class="lineNum">      14 </span>            : //
<span class="lineNum">      15 </span>            : 
<span class="lineNum">      16 </span>            : #include &lt;memory&gt; // boost.TR1 include order fix
<span class="lineNum">      17 </span>            : #include &lt;boost/smart_ptr/detail/shared_count.hpp&gt;
<span class="lineNum">      18 </span>            : #include &lt;boost/smart_ptr/shared_ptr.hpp&gt;
<span class="lineNum">      19 </span>            : 
<span class="lineNum">      20 </span>            : namespace boost
<span class="lineNum">      21 </span>            : {
<span class="lineNum">      22 </span>            : 
<span class="lineNum">      23 </span><span class="lineNoCov">          0 : template&lt;class T&gt; class weak_ptr</span>
<span class="lineNum">      24 </span>            : {
<span class="lineNum">      25 </span>            : private:
<span class="lineNum">      26 </span>            : 
<span class="lineNum">      27 </span>            :     // Borland 5.5.1 specific workarounds
<span class="lineNum">      28 </span>            :     typedef weak_ptr&lt;T&gt; this_type;
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span>            : public:
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            :     typedef typename boost::detail::sp_element&lt; T &gt;::type element_type;
<span class="lineNum">      33 </span>            : 
<span class="lineNum">      34 </span><span class="lineCov">          2 :     weak_ptr() BOOST_NOEXCEPT : px(0), pn() // never throws in 1.30+</span>
<span class="lineNum">      35 </span>            :     {
<span class="lineNum">      36 </span>            :     }
<span class="lineNum">      37 </span>            : 
<span class="lineNum">      38 </span>            : //  generated copy constructor, assignment, destructor are fine...
<span class="lineNum">      39 </span>            : 
<span class="lineNum">      40 </span>            : #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
<span class="lineNum">      41 </span>            : 
<span class="lineNum">      42 </span>            : // ... except in C++0x, move disables the implicit copy
<span class="lineNum">      43 </span>            : 
<span class="lineNum">      44 </span>            :     weak_ptr( weak_ptr const &amp; r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
<span class="lineNum">      45 </span>            :     {
<span class="lineNum">      46 </span>            :     }
<span class="lineNum">      47 </span>            : 
<span class="lineNum">      48 </span>            :     weak_ptr &amp; operator=( weak_ptr const &amp; r ) BOOST_NOEXCEPT
<span class="lineNum">      49 </span>            :     {
<span class="lineNum">      50 </span>            :         px = r.px;
<span class="lineNum">      51 </span>            :         pn = r.pn;
<span class="lineNum">      52 </span>            :         return *this;
<span class="lineNum">      53 </span>            :     }
<span class="lineNum">      54 </span>            : 
<span class="lineNum">      55 </span>            : #endif
<span class="lineNum">      56 </span>            : 
<span class="lineNum">      57 </span>            : //
<span class="lineNum">      58 </span>            : //  The &quot;obvious&quot; converting constructor implementation:
<span class="lineNum">      59 </span>            : //
<span class="lineNum">      60 </span>            : //  template&lt;class Y&gt;
<span class="lineNum">      61 </span>            : //  weak_ptr(weak_ptr&lt;Y&gt; const &amp; r): px(r.px), pn(r.pn) // never throws
<span class="lineNum">      62 </span>            : //  {
<span class="lineNum">      63 </span>            : //  }
<span class="lineNum">      64 </span>            : //
<span class="lineNum">      65 </span>            : //  has a serious problem.
<span class="lineNum">      66 </span>            : //
<span class="lineNum">      67 </span>            : //  r.px may already have been invalidated. The px(r.px)
<span class="lineNum">      68 </span>            : //  conversion may require access to *r.px (virtual inheritance).
<span class="lineNum">      69 </span>            : //
<span class="lineNum">      70 </span>            : //  It is not possible to avoid spurious access violations since
<span class="lineNum">      71 </span>            : //  in multithreaded programs r.px may be invalidated at any point.
<span class="lineNum">      72 </span>            : //
<span class="lineNum">      73 </span>            : 
<span class="lineNum">      74 </span>            :     template&lt;class Y&gt;
<span class="lineNum">      75 </span>            : #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
<span class="lineNum">      76 </span>            : 
<span class="lineNum">      77 </span>            :     weak_ptr( weak_ptr&lt;Y&gt; const &amp; r, typename boost::detail::sp_enable_if_convertible&lt;Y,T&gt;::type = boost::detail::sp_empty() )
<span class="lineNum">      78 </span>            : 
<span class="lineNum">      79 </span>            : #else
<span class="lineNum">      80 </span>            : 
<span class="lineNum">      81 </span>            :     weak_ptr( weak_ptr&lt;Y&gt; const &amp; r )
<span class="lineNum">      82 </span>            : 
<span class="lineNum">      83 </span>            : #endif
<span class="lineNum">      84 </span>            :     BOOST_NOEXCEPT : px(r.lock().get()), pn(r.pn)
<span class="lineNum">      85 </span>            :     {
<span class="lineNum">      86 </span>            :         boost::detail::sp_assert_convertible&lt; Y, T &gt;();
<span class="lineNum">      87 </span>            :     }
<span class="lineNum">      88 </span>            : 
<span class="lineNum">      89 </span>            : #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
<span class="lineNum">      90 </span>            : 
<span class="lineNum">      91 </span>            :     template&lt;class Y&gt;
<span class="lineNum">      92 </span>            : #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
<span class="lineNum">      93 </span>            : 
<span class="lineNum">      94 </span>            :     weak_ptr( weak_ptr&lt;Y&gt; &amp;&amp; r, typename boost::detail::sp_enable_if_convertible&lt;Y,T&gt;::type = boost::detail::sp_empty() )
<span class="lineNum">      95 </span>            : 
<span class="lineNum">      96 </span>            : #else
<span class="lineNum">      97 </span>            : 
<span class="lineNum">      98 </span>            :     weak_ptr( weak_ptr&lt;Y&gt; &amp;&amp; r )
<span class="lineNum">      99 </span>            : 
<span class="lineNum">     100 </span>            : #endif
<span class="lineNum">     101 </span>            :     BOOST_NOEXCEPT : px( r.lock().get() ), pn( static_cast&lt; boost::detail::weak_count &amp;&amp; &gt;( r.pn ) )
<span class="lineNum">     102 </span>            :     {
<span class="lineNum">     103 </span>            :         boost::detail::sp_assert_convertible&lt; Y, T &gt;();
<span class="lineNum">     104 </span>            :         r.px = 0;
<span class="lineNum">     105 </span>            :     }
<span class="lineNum">     106 </span>            : 
<span class="lineNum">     107 </span>            :     // for better efficiency in the T == Y case
<span class="lineNum">     108 </span>            :     weak_ptr( weak_ptr &amp;&amp; r )
<span class="lineNum">     109 </span>            :     BOOST_NOEXCEPT : px( r.px ), pn( static_cast&lt; boost::detail::weak_count &amp;&amp; &gt;( r.pn ) )
<span class="lineNum">     110 </span>            :     {
<span class="lineNum">     111 </span>            :         r.px = 0;
<span class="lineNum">     112 </span>            :     }
<span class="lineNum">     113 </span>            : 
<span class="lineNum">     114 </span>            :     // for better efficiency in the T == Y case
<span class="lineNum">     115 </span>            :     weak_ptr &amp; operator=( weak_ptr &amp;&amp; r ) BOOST_NOEXCEPT
<span class="lineNum">     116 </span>            :     {
<span class="lineNum">     117 </span>            :         this_type( static_cast&lt; weak_ptr &amp;&amp; &gt;( r ) ).swap( *this );
<span class="lineNum">     118 </span>            :         return *this;
<span class="lineNum">     119 </span>            :     }
<span class="lineNum">     120 </span>            : 
<span class="lineNum">     121 </span>            : 
<span class="lineNum">     122 </span>            : #endif
<span class="lineNum">     123 </span>            : 
<span class="lineNum">     124 </span>            :     template&lt;class Y&gt;
<span class="lineNum">     125 </span>            : #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
<span class="lineNum">     126 </span>            : 
<span class="lineNum">     127 </span>            :     weak_ptr( shared_ptr&lt;Y&gt; const &amp; r, typename boost::detail::sp_enable_if_convertible&lt;Y,T&gt;::type = boost::detail::sp_empty() )
<span class="lineNum">     128 </span>            : 
<span class="lineNum">     129 </span>            : #else
<span class="lineNum">     130 </span>            : 
<span class="lineNum">     131 </span>            :     weak_ptr( shared_ptr&lt;Y&gt; const &amp; r )
<span class="lineNum">     132 </span>            : 
<span class="lineNum">     133 </span>            : #endif
<span class="lineNum">     134 </span>            :     BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
<span class="lineNum">     135 </span>            :     {
<span class="lineNum">     136 </span>            :         boost::detail::sp_assert_convertible&lt; Y, T &gt;();
<span class="lineNum">     137 </span>            :     }
<span class="lineNum">     138 </span>            : 
<span class="lineNum">     139 </span>            : #if !defined(BOOST_MSVC) || (BOOST_MSVC &gt;= 1300)
<span class="lineNum">     140 </span>            : 
<span class="lineNum">     141 </span>            :     template&lt;class Y&gt;
<span class="lineNum">     142 </span>            :     weak_ptr &amp; operator=( weak_ptr&lt;Y&gt; const &amp; r ) BOOST_NOEXCEPT
<span class="lineNum">     143 </span>            :     {
<span class="lineNum">     144 </span>            :         boost::detail::sp_assert_convertible&lt; Y, T &gt;();
<span class="lineNum">     145 </span>            : 
<span class="lineNum">     146 </span>            :         px = r.lock().get();
<span class="lineNum">     147 </span>            :         pn = r.pn;
<span class="lineNum">     148 </span>            : 
<span class="lineNum">     149 </span>            :         return *this;
<span class="lineNum">     150 </span>            :     }
<span class="lineNum">     151 </span>            : 
<span class="lineNum">     152 </span>            : #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
<span class="lineNum">     153 </span>            : 
<span class="lineNum">     154 </span>            :     template&lt;class Y&gt;
<span class="lineNum">     155 </span>            :     weak_ptr &amp; operator=( weak_ptr&lt;Y&gt; &amp;&amp; r ) BOOST_NOEXCEPT
<span class="lineNum">     156 </span>            :     {
<span class="lineNum">     157 </span>            :         this_type( static_cast&lt; weak_ptr&lt;Y&gt; &amp;&amp; &gt;( r ) ).swap( *this );
<span class="lineNum">     158 </span>            :         return *this;
<span class="lineNum">     159 </span>            :     }
<span class="lineNum">     160 </span>            : 
<span class="lineNum">     161 </span>            : #endif
<span class="lineNum">     162 </span>            : 
<span class="lineNum">     163 </span>            :     template&lt;class Y&gt;
<span class="lineNum">     164 </span>            :     weak_ptr &amp; operator=( shared_ptr&lt;Y&gt; const &amp; r ) BOOST_NOEXCEPT
<span class="lineNum">     165 </span>            :     {
<span class="lineNum">     166 </span>            :         boost::detail::sp_assert_convertible&lt; Y, T &gt;();
<span class="lineNum">     167 </span>            : 
<span class="lineNum">     168 </span><span class="lineCov">          2 :         px = r.px;</span>
<span class="lineNum">     169 </span><span class="lineCov">          2 :         pn = r.pn;</span>
<span class="lineNum">     170 </span>            : 
<span class="lineNum">     171 </span>            :         return *this;
<span class="lineNum">     172 </span>            :     }
<span class="lineNum">     173 </span>            : 
<span class="lineNum">     174 </span>            : #endif
<span class="lineNum">     175 </span>            : 
<span class="lineNum">     176 </span>            :     shared_ptr&lt;T&gt; lock() const BOOST_NOEXCEPT
<span class="lineNum">     177 </span>            :     {
<span class="lineNum">     178 </span>            :         return shared_ptr&lt;T&gt;( *this, boost::detail::sp_nothrow_tag() );
<span class="lineNum">     179 </span>            :     }
<span class="lineNum">     180 </span>            : 
<span class="lineNum">     181 </span>            :     long use_count() const BOOST_NOEXCEPT
<span class="lineNum">     182 </span>            :     {
<span class="lineNum">     183 </span>            :         return pn.use_count();
<span class="lineNum">     184 </span>            :     }
<span class="lineNum">     185 </span>            : 
<span class="lineNum">     186 </span>            :     bool expired() const BOOST_NOEXCEPT
<span class="lineNum">     187 </span>            :     {
<span class="lineNum">     188 </span>            :         return pn.use_count() == 0;
<span class="lineNum">     189 </span>            :     }
<span class="lineNum">     190 </span>            : 
<span class="lineNum">     191 </span>            :     bool _empty() const // extension, not in std::weak_ptr
<span class="lineNum">     192 </span>            :     {
<span class="lineNum">     193 </span>            :         return pn.empty();
<span class="lineNum">     194 </span>            :     }
<span class="lineNum">     195 </span>            : 
<span class="lineNum">     196 </span>            :     void reset() BOOST_NOEXCEPT // never throws in 1.30+
<span class="lineNum">     197 </span>            :     {
<span class="lineNum">     198 </span>            :         this_type().swap(*this);
<span class="lineNum">     199 </span>            :     }
<span class="lineNum">     200 </span>            : 
<span class="lineNum">     201 </span>            :     void swap(this_type &amp; other) BOOST_NOEXCEPT
<span class="lineNum">     202 </span>            :     {
<span class="lineNum">     203 </span>            :         std::swap(px, other.px);
<span class="lineNum">     204 </span>            :         pn.swap(other.pn);
<span class="lineNum">     205 </span>            :     }
<span class="lineNum">     206 </span>            : 
<span class="lineNum">     207 </span>            :     template&lt;typename Y&gt;
<span class="lineNum">     208 </span>            :     void _internal_aliasing_assign(weak_ptr&lt;Y&gt; const &amp; r, element_type * px2)
<span class="lineNum">     209 </span>            :     {
<span class="lineNum">     210 </span>            :         px = px2;
<span class="lineNum">     211 </span>            :         pn = r.pn;
<span class="lineNum">     212 </span>            :     }
<span class="lineNum">     213 </span>            : 
<span class="lineNum">     214 </span>            :     template&lt;class Y&gt; bool owner_before( weak_ptr&lt;Y&gt; const &amp; rhs ) const BOOST_NOEXCEPT
<span class="lineNum">     215 </span>            :     {
<span class="lineNum">     216 </span>            :         return pn &lt; rhs.pn;
<span class="lineNum">     217 </span>            :     }
<span class="lineNum">     218 </span>            : 
<span class="lineNum">     219 </span>            :     template&lt;class Y&gt; bool owner_before( shared_ptr&lt;Y&gt; const &amp; rhs ) const BOOST_NOEXCEPT
<span class="lineNum">     220 </span>            :     {
<span class="lineNum">     221 </span>            :         return pn &lt; rhs.pn;
<span class="lineNum">     222 </span>            :     }
<span class="lineNum">     223 </span>            : 
<span class="lineNum">     224 </span>            : // Tasteless as this may seem, making all members public allows member templates
<span class="lineNum">     225 </span>            : // to work in the absence of member template friends. (Matthew Langston)
<span class="lineNum">     226 </span>            : 
<span class="lineNum">     227 </span>            : #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
<span class="lineNum">     228 </span>            : 
<span class="lineNum">     229 </span>            : private:
<span class="lineNum">     230 </span>            : 
<span class="lineNum">     231 </span>            :     template&lt;class Y&gt; friend class weak_ptr;
<span class="lineNum">     232 </span>            :     template&lt;class Y&gt; friend class shared_ptr;
<span class="lineNum">     233 </span>            : 
<span class="lineNum">     234 </span>            : #endif
<span class="lineNum">     235 </span>            : 
<span class="lineNum">     236 </span>            :     element_type * px;            // contained pointer
<span class="lineNum">     237 </span>            :     boost::detail::weak_count pn; // reference counter
<span class="lineNum">     238 </span>            : 
<span class="lineNum">     239 </span>            : };  // weak_ptr
<span class="lineNum">     240 </span>            : 
<span class="lineNum">     241 </span>            : template&lt;class T, class U&gt; inline bool operator&lt;(weak_ptr&lt;T&gt; const &amp; a, weak_ptr&lt;U&gt; const &amp; b) BOOST_NOEXCEPT
<span class="lineNum">     242 </span>            : {
<span class="lineNum">     243 </span>            :     return a.owner_before( b );
<span class="lineNum">     244 </span>            : }
<span class="lineNum">     245 </span>            : 
<span class="lineNum">     246 </span>            : template&lt;class T&gt; void swap(weak_ptr&lt;T&gt; &amp; a, weak_ptr&lt;T&gt; &amp; b) BOOST_NOEXCEPT
<span class="lineNum">     247 </span>            : {
<span class="lineNum">     248 </span>            :     a.swap(b);
<span class="lineNum">     249 </span>            : }
<span class="lineNum">     250 </span>            : 
<span class="lineNum">     251 </span>            : } // namespace boost
<span class="lineNum">     252 </span>            : 
<span class="lineNum">     253 </span>            : #endif  // #ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
